<?php

require __DIR__ . '/../../vendor/autoload.php';
require __DIR__ . '/../Mqtt.php';

$mqtt = new Mqtt;
$mqtt->createChannel();
$mqtt->createExchange('router-exchange', 'direct');


$routerKeys = ['info', 'error'];
$i = 1;
while(true) {
    $msg = "hello,mqtt_{$i}\n";
    $key = $i%2;
    $mqtt->publishMsg($msg, [], $routerKeys[$key]);
    echo $msg;
    $i++;

    sleep(1);
}

$mqtt->close();
